<template>
	<div>
		<el-card class="box-card" style="margin-top:15px">
			<div slot="header" class="clearfix">
				<span style="font-weight: bold">诊断病人要素</span>
			</div>
			<el-row :gutter="15">
				<el-form class="demo-form-inline" label-width="100px">
					<el-col :span="12">
						<el-form-item label="诊断" style="width:100%;" class="s_selectbox" v-if="zdFlag">
							<div class="dialogFirstRow2">
								<el-input v-model="zdVal" :readonly="true" size="mini" style="width:230px;"></el-input>
								<input type="hidden" v-model="submit.zd_code">
								<el-button type="primary" size="mini" @click="openSelect('诊断',submit.zd_code)">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun('诊断')">清除</el-button>
							</div>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="妊娠">
							<el-select v-model="submit.rs_code" size="small" placeholder="请选择">
								<el-option
								  v-for="item in rsOptions"
								  :key="item.value"
								  :label="item.label"
								  :value="item.value">
								</el-option>
							  </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12" v-if="gzFlag">
						<el-form-item label="肝损">
							<el-select v-model="submit.gs_code" size="small" placeholder="请选择">
								<el-option
								  v-for="item in gsOptions"
								  :key="item.value"
								  :label="item.label"
								  :value="item.value">
								</el-option>
							  </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="肾损">
							<el-select v-model="submit.ss_code" size="small" placeholder="请选择">
								<el-option
								  v-for="item in ssOptions"
								  :key="item.value"
								  :label="item.label"
								  :value="item.value">
								</el-option>
							  </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="过敏源" style="width:100%;" class="s_selectbox">
							<div class="dialogFirstRow2">
								<el-input v-model="gmyVal" :readonly="true" size="mini" style="width:230px;"></el-input>
								<input type="hidden" v-model="submit.gmy_code">
								<el-button type="primary" size="mini" @click="openSelect('过敏源',submit.gmy_code)">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun('过敏源')">清除</el-button>
							</div>
						</el-form-item>
					</el-col>
					<el-col :span="12" v-if="ssFlag">
						<el-form-item label="手术选择" style="width:100%;" class="s_selectbox">
							<div class="dialogFirstRow2">
								<el-input v-model="ssxzVal" :readonly="true" size="mini" style="width:230px;"></el-input>
								<input type="hidden" v-model="submit.operation_code">
								<el-button type="primary" size="mini" @click="openSelect('手术',submit.operation_code)">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun('手术')">清除</el-button>
							</div>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="检验" style="width:100%;" class="s_selectbox">
							<div class="dialogFirstRow2">
								<el-input v-model="jyVal" :readonly="true" size="mini" style="width:230px;"></el-input>
								<input type="hidden" v-model="submit.jy_code">
								<el-button type="primary" size="mini" @click="jyShow">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun('检验')">清除</el-button>
							</div>
						</el-form-item>
					</el-col>
					<el-col :span="12" v-if="gytjFlag">
						<el-form-item label="给药途径" style="width:100%;" class="s_selectbox">
							<div class="dialogFirstRow2">
								<el-input v-model="gytjVal" :readonly="true" size="mini" style="width:230px;"></el-input>
								<input type="hidden" v-model="submit.route_code">
								<el-button type="primary" size="mini" @click="openSelect('给药途径',submit.route_code)">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun('给药途径')">清除</el-button>
							</div>
						</el-form-item>
					</el-col>
				</el-form>
			</el-row>
		</el-card>
	</div>
</template>

<script>
	export default {
		name:"ZdbrysCard",
		data () {
			return {
				rsOptions:[{
					  value: '',
					  label: '不选择'
					}, {
					  value: '1',
					  label: '是'
					}, {
					  value: '2',
					  label: '否'
				}],//妊娠options
				gsOptions:[{
					  value: '',
					  label: '不选择'
					}, {
					  value: '1',
					  label: '轻度'
					}, {
					  value: '2',
					  label: '中度'
					}, {
					  value: '3',
					  label: '重度'
				}],//肝损options
				ssOptions:[{
					  value: '',
					  label: '不选择'
					}, {
					  value: '1',
					  label: '轻度'
					}, {
					  value: '2',
					  label: '中度'
					}, {
					  value: '3',
					  label: '重度'
				}],//肾损options
				zdVal:"",//诊断value
				gmyVal:"",//过敏源value
				ssxzVal:"",//手术选择value
				jyVal:"",//检验value
				gytjVal:"",//给药途径value
				submit:{
					zd_code:"",
					rs_code:"",
					gs_code:"",
					ss_code:"",
					gmy_code:"",
					operation_code:"",
					jy_code:"",
					jy_value:"",
					jy_unequal:"",
					route_code:""
				}
			}
		},
		props:{
			zdData:{
				type:Object
			},
			gmyData:{
				type:Object
			},
			ssData:{
				type:Object
			},
			jyData:{
				type:Object
			},
			gytjData:{
				type:Object
			},
			zdFlag:{
				default:true
			},
			gytjFlag:{
				default:true
			},
			ssFlag:{
				default:true
			},
			gzFlag:{
				default:true
			}
		},
		watch:{
			zdData(val){
				if(this.zdFlag){
					this.zdVal=val.name;
					this.submit.zd_code=val.id
				}
			},
			gmyData(val){
				this.gmyVal=val.name;
				this.submit.gmy_code=val.id
			},
			ssData(val){
				if(this.ssFlag){
					this.ssxzVal=val.name;
					this.submit.operation_code=val.id
				}
			},
			jyData(val){
				this.jyVal=val.name;
				this.submit.jy_code=val.id
				this.submit.jy_unequal=val.unequal
				this.submit.jy_value=val.value
			},
			gytjData(val){
				if(this.gytjFlag){
					this.gytjVal=val.name;
					this.submit.route_code=val.id
				}
			}
		},
		methods:{
			openSelect (type,checkId) {
				this.$emit("selectPop",type,checkId);
			},
			jyShow(){
				this.$emit("jyShow");
			},
			clearFun(type){
				switch (type){
					case '诊断':
						this.zdVal="";
						this.submit.zd_code="";
						break;
					case '过敏源':
						this.gmyVal="";
						this.submit.gmy_code="";
						break;
					case '手术':
						this.ssxzVal="";
						this.submit.operation_code="";
						break;
					case '检验':
						this.jyVal="";
						this.submit.jy_code="";
						this.submit.jy_value="";
						this.submit.jy_unequal="";
						break;
					case '给药途径':
						this.gytjVal="";
						this.submit.route_code="";
						break;
				}
			},
			resetFun(){
				this.zdVal="";
				this.gmyVal="";
				this.ssxzVal="";
				this.jyVal="";
				this.gytjVal="";
				this.submit={
					zd_code:"",
					rs_code:"",
					gs_code:"",
					ss_code:"",
					gmy_code:"",
					operation_code:"",
					jy_code:"",
					jy_value:"",
					jy_unequal:"",
					route_code:""
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.el-card {
		margin-left: 3px;
	}
	.dialogFirstRow>>>.el-input {
		width: 70px;
		margin-right: 10px;
	}

	.el-form-item.s_selectbox>>>.el-form-item__content {
		width: 80%;
	}


	.demo-form-inline>>>.el-form-item {
		margin-bottom: 0px;
	}

	.dialogFirstRow>>>label {
		height:41px;
		display:inline-block;
	}
</style>
